#!/bin/bash

# Setup our paths as needed
[[ "$PATH" =~ "$BASHMASTERS" ]] || {
    PATH="$HOME/bash-masters:$BASHMASTERS:$PATH";
}

[[ "$1" = '' ]] && {
    set -- core.sh  # This enforces a source of the core itself.
} || {
    # Auto load the core if we are not loading it,
    # and it is not loaded.
    [[ $(type -t assert 2>&1) = function ]] || source core.sh;
}


[[ "$1" =~ ^-d$|^--direct-path$ ]] && {

    # This option states to explicitly source a file by
    # its path name.
    
    shift;
    assert "$1" is existing file && {
        MASTERFILE="$1";    
    } || assert "$1" is shell file && {
        MASTERFILE=$(type -p "$1");
    } || {
        true this operation is going to fail!
    }
    shift;
    
} || {

    MASTERFILE="$1";
    shift 1;
            
}

source "${MASTERFILE}" "$@";

unset MASTERFILE;

